﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ORMEF
{
    public class DbInitializer :DropCreateDatabaseIfModelChanges<Admin520DbContex>
    {
        protected override void Seed(Admin520DbContex context)
        {
            var brand1 = new Brands
            {
                BrandName = "苹果"
            };

            var brand2 = new Brands
            {
                BrandName = "西瓜"
            };

            context.Brands.Add(brand1);

            context.Brands.Add(brand2);

            context.SaveChanges();

            var prod1 = new Product
            {
                ProductName = "苹果 X",
                ShortDesc = "挺好用的",
                DetailDesc = "苹果是由乔普斯创立的一家科技公司",
                BrandsId = brand1.Id
            };

            context.Products.Add(prod1);

            context.SaveChanges();
            base.Seed(context);
        }
    }
}
